#include <iostream>
using namespace std;
#define maxn 2000005
#define inf 0x4fffffff
int n, k;
struct node
{
    int val, pos;
    node(int val = -inf, int pos = -inf) : val(val), pos(pos){};
};
node que[maxn];
int arr[maxn];
void getMaxQue()
{
    int front = 0, tail = 0;
    for (int i = 1; i <= n; ++i)
    {
        while (front <= tail && que[tail].val <= arr[i])
            tail--;
        que[++tail] = node(arr[i], i);
        while (front <= tail && que[front].pos + k <= i)
            front++;
        if (i >= k)
            printf("%d\n", que[front].val);
    }
}
int main()
{
    cin >> n >> k;
    for (int i = 1; i <= n; ++i)
        scanf("%d", &arr[i]);
    getMaxQue();
    return 0;
}